package com.story.story_serve.service.Book;

import com.story.story_pojo.Book.BookCar;
import com.story.story_pojo.Book.BookCarList;
import com.story.story_pojo.userinfo;
import com.story.story_serve.mapper.Book.BookCarMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * ClassName:  BookCarService
 * description:
 *
 * @ author:郭海龙
 * @ Create：2024/6/2 21:46
 * @ Version:1.0
 */
@Service
public class BookCarService {

    @Autowired
    private BookCarMapper bookCarMapper;

    // 添加书单
    public String addBookcar(BookCar bookCar) {
        int i = bookCarMapper.insert(bookCar);
        if (i == 0){
            return "添加失败";
        }else {
            return "添加成功";
        }
    }

    // 获取书单数据
    public List<BookCarList> getBookCarList(HttpSession session) {
        userinfo user = (userinfo)session.getAttribute("user");
        String username = user.getUsername();
        return bookCarMapper.getBookCarList(username);

    }
}
